# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        Young  
# Name:         demo5.05
# Description:
# Author:       asus
# Date:         2019/2/28
#-------------------------------------------------------------------------------


#包含了2个空的大括号，format方法需要按顺序指定格式化参数值
s1 = "Today is {},the temperature is {} degrees."
#format方法的第一个参数值对应s1的第一对大括号，第二个亦是
print(s1.format("Saturday",24))

#包含了两个命名格式化参数，一个是{week}，一个是{degree}
s2 = "Today is {week},the temperature is {degree} degrees"
print(s2.format(week = "Wednesday",degree = 22))

#混合了顺序格式化参数和关键字格式化参数两种方式
s3 = "Today is {week},{},the {} temperature is {degree} degrees."
print(s3.format("aaaaa",12345,week = "Wednesday",degree = 8))

#为顺序格式化参数指定了从format方法获取参数值的顺序，{1}表示从format方法的第2个取
s4 = "Today is {week},{1},the {0} temperature is {degree} degrees."
print(s4.format('mlgb',51165,week = 'Thursday',degree = 8))
print(s4.format(51165,'mlgb',week = 'Friday',degree = 8))

#定义了一个列表
fullname = ["Bill","Gates"]
#format通过关键字参数，为name名字指定了fullname列表
print("Mr {name[1]}".format(name = fullname))

#导入math模块
import math
s5 = "The module defines the value {mod.pi} for PI"
print(s5.format(mod = math))

print("{first!s} {first!r} {first!a}".format(first = "中"))